﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CutShuFa.AutoAction
{
    public class ActionRemoveContoursByArea : AAutoAction
    {
        public override string ActionName{get;} = "移除小轮廓";

        public override List<Parameter> GetParameters()
        {
            if (parameters == null)
            {
                parameters = new List<Parameter>();
                parameters.Add(new Parameter() { Name = "area", Value = "10", Type = ParameterType.Int });
            }
            return parameters;
        }

        public override void Run(AutoActionData data)
        {
            if (data.contours == null)
            {
                return;
            }
            if (this.parameters == null)
            {
                GetParameters();
            }
            int area = int.Parse(parameters.Where(p => p.Name == "area").FirstOrDefault().Value);
            data.RemoveContoursByArea(area);
        }
    }
}
